# -*- coding: utf-8 -*-
# @Time    : 2025/4/18 11:19
# @Author  : yxb
# @Email   : 18282090563@163.com
# @File    : appium_test1.py
# @Software: PyCharm
import unittest
from appium import webdriver
from appium.options.android import UiAutomator2Options
from  appium.webdriver.common.appiumby import  AppiumBy

capabilities = dict(
    platformName='Android', # 平台类型
    automationName='uiautomator2', # 驱动类型
    deviceName='127.0.0.1:62001',# 设备名称
    appPackage='com.android.settings',# 被测app包名称
    appActivity='.Settings',# 被测app主activity名称
    noReset=True, # 启动app不重置
    forceAppLaunch=True,
    shouldTerminateApp=True
)
appium_server_url = "http://localhost:4723"

class TestAppium(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Remote(appium_server_url,options=UiAutomator2Options().load_capabilities(capabilities))

    def tearDown(self):
                if self.driver:
                    self.driver.quit()

    def test_find_battery(self):
                el  = self.driver.find_element(by=AppiumBy.XPATH,value='//*[@text="电池"]')
                el.click()


if __name__=='__main__':
    unittest.main()



























